class conversions:
    def convertTo2(self,x): #convert to 2's complement 32-bit
        return x & 0xffffffff
    
    def Convert2ToDecimal(self,x): #convert 2's complement to decimal
        if ( (x>>31) == 1 ):
            return -( (~x & 0xffffffff) + 1)
        else:
            return x
        
    def signExtend(self,x):
        if ( (x>>15) == 1 ):
            return 0xFFFF0000 + x
        else:
            return x